define([
        'underscore',
        'text!app/tpl/NotSupportBrowserTpl.html',
        'text!app/tpl/AdminHeaderTpl.html',
        'text!app/tpl/SideBarTpl.html',
        
        'app/utils/CommonUtils'
        ], function (
		_,
		NotSupportBrowserTpl,
        AdminHeaderTpl,
        SideBarTpl
        
    ) {


	return {
		
		confirm:function(content, ok_func, cancel_func){
			
			if($(".am-modal-confirm").length == 0){
		    	var a = $(
		    			'<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">'+
			  			  '<div class="am-modal-dialog">'+
						    '<div class="am-modal-hd">温馨提示</div>'+
						    '<div class="am-modal-bd">'+
						    	'<div class="am-modal-confirm-content">'+content+'</div>'+
						    '</div>'+
						    '<div class="am-modal-footer">'+
						      '<span class="am-modal-btn" data-am-modal-cancel>取消</span>'+
						      '<span class="am-modal-btn" data-am-modal-confirm>确定</span>'+
						    '</div>'+
						  '</div>'+
						'</div>'
		    			);
		    	$("body").append(a);
			}else{
				$(".am-modal-confirm").find(".am-modal-confirm-content").html(content);
			}
			
	    	$(".am-modal-confirm").modal({
	            relatedTarget: this,
	            onConfirm: function(options) {
	            	ok_func();
	            },
	            // closeOnConfirm: false,
	            onCancel: function() {
	            	cancel_func();
	            }
	          });
			
		},
		alert:function(content){
	    	
			if($(".am-modal-alert").length == 0){
		    	var a = $(
		    			'<div class="am-modal am-modal-alert" tabindex="-1">'+
		    	    	  '<div class="am-modal-dialog">'+
		    	    	    '<div class="am-modal-hd">温馨提示</div>'+
		    	    	    '<div class="am-modal-bd">'+
		    	    	      '<span class="am-modal-alert-content">'+content+'</span>'+
		    	    	    '</div>'+
		    	    	    '<div class="am-modal-footer">'+
		    	    	      '<span class="am-modal-btn">确定</span>'+
		    	    	    '</div>'+
		    	    	  '</div>'+
		    	    	'</div>'
		    			);
		    	$("body").append(a);
			}else{
				$(".am-modal-alert").find(".am-modal-alert-content").text(content);
			}
	    	$(".am-modal-alert").modal();
	    },

		inputClear:function($el){
			$el.val("");
		},
		inputOriginalUpdate:function($el){
			$el.data("original",$el.val());
		},
		inputRevert:function($el){
			$el.val($el.data("original"));
		},
		inputInt:function($el, val){
			$el.val(val);
			$el.data("original",val);
		},
		
		imageRevert:function($el){
			$el.attr("src",$el.data("original"));
		},
		imageInt:function($el,val){
			$el.attr("src",val);
			$el.data("original",val);
		},
		
		adminPageInt:function(opt){
//			
//			$(".admin-sidebar-list").hide();
//			
//			var sidebarPanel1 = $(
//					'<div class="am-panel am-panel-default admin-sidebar-panel" style="background-color:rgb(31,38,55);color:white;border: rgb(31,38,55);margin-left:0;margin-right:0;">'+
//			        	'<div class="am-panel-bd">'+
//							'<p><span class="am-icon-tag"></span> 公告</p>'+
//			          		'<p>PPT+语音培训、视频培训，支持直播与回放。</p>'+
//			        	'</div>'+
//					'</div>');
//
//			var sidebarPanel2 = $(
//					'<div class="am-panel am-panel-default admin-sidebar-panel" style="background-color:rgb(31,38,55);color:white;border: rgb(31,38,55);margin-left:0;margin-right:0;">'+
//				        '<div class="am-panel-bd">'+
//				          '<p><span class="am-icon-tag"></span> 小提示</p>'+
//				          '<p>通过设置访问密码可以限制未知用户的访问</p>'+
//				        '</div>'+
//				      '</div>');
//			
//			var transitBar = $(
//					'<div style="width:100%;height:6px;background: url(assets/i/transit1.jpg) repeat">&nbsp;</div>'
//			);
//			
//			$(".admin-offcanvas-bar").append(sidebarPanel1);
//			$(".admin-offcanvas-bar").append(transitBar);
//			$(".admin-offcanvas-bar").append(sidebarPanel2);
//			$(".admin-offcanvas-bar").append(transitBar);

			var homeli = $('<li><a href="admin-index.html"><span class="am-icon-home"></span> 我的微讲堂'+
//					'<span class="am-badge am-badge-secondary am-margin-right am-fr">0</span>'+
					'</a></li>');
			var formli = $('<li><a href="admin-form.html"><span class="am-icon-puzzle-piece"></span> 报名管理</a></li>');
			var profileli = $('<li><a href="admin-user.html"><span class="am-icon-user"></span> 个人资料</a></li>');
		    var membersli = $('<li><a href="admin-member.html"><span class="am-icon-users"></span> 用户管理</a></li>');
		    var catalogsli = $('<li><a href="admin-catalogs.html"><span class="am-icon-bookmark"></span> 分类管理</a></li>');
		    var settingli = $('<li><a href="admin-setting.html"><span class="am-icon-th"></span> 系统设置</a></li>');
		
		    
		    if(!$.isNull(opt.useruuid) && opt.useruuid != "sa"){
		    	
		    	$(".admin-sidebar-list").find("li:last").before(homeli);
		    	//$(".admin-sidebar-list").find("li:last").before(formli);
		    	$(".admin-sidebar-list").find("li:last").before(profileli);
		    }

		    if(!$.isNull(opt.isAdmin) && opt.isAdmin == "1"){
				//admin
		    	$(".admin-sidebar-list").find("li:last").before(membersli);
		    	$(".admin-sidebar-list").find("li:last").before(catalogsli);
		    	$(".admin-sidebar-list").find("li:last").before(settingli);
				
			}

			$(".wjt-admin-copyright").text(opt.copyrighttext);
			
			$(".wjt-username").text(opt.username);
			$(".wjt-admin-name").text(opt.navi_main);
			$(".wjt-admin-subname").text(opt.navi_sub);
			
			
			$(".wjt-admin-copyright").text(opt.admin_copyright);
			$(".wjt-admin-copyright").hide();
		},
		openAmTab:function(){
			var tab = $.getUrlParam("tab");
			$(".am-tabs").tabs('open', parseInt(tab)-1);
		}
	};

});
